// 接口方法 获取频道列表
import request from '@/utils/request'
import { getToken } from '@/utils/token'

// 登录接口
export const loginAPI = ({ mobile, code }) => request({
  url: '/v1_0/authorizations',
  method: 'POST',
  data: {
    mobile: mobile,
    code: code
  }
})
// 获取用户频道数据
export const getUserChannelListAPI = () => request({
  url: '/v1_0/user/channels',
  headers: {
    Authorization: `Bearer ${getToken()}`
  }
})

// 获取所有频道
export const getChannelListAPI = () => request({
  url: '/v1_0/channels'
})

// 获取文章列表
export const getArticleListAPI = ({ channel_id, timestamp = new Date() }) => {
  // console.log(1111)
  return request({
    url: '/v1_0/articles',
    method: 'GET',
    headers: {
      Authorization: `Bearer ${getToken()}`
    },
    params: {
      channel_id,
      timestamp
    }
  })
}

// 不感兴趣接口
export const dislikeArticleAPI = (artId) => request({
  url: 'v1_0/article/dislikes',
  method: 'POST',
  headers: {
    Authorization: `Bearer ${getToken()}`
  },
  data: {
    target: artId
  }
})

// 举报文章
